import java.util.Scanner;

public class t1
{
	public static void main(String[] args){
		System.out.println("Please enter the year");
        Scanner s1 = new Scanner(System.in);
        int Year = s1.nextInt();
        System.out.println("Please enter the month");
        Scanner s2 = new Scanner(System.in);
        int Mon = s2.nextInt();
        System.out.println("Please enter the day");
        Scanner s3 = new Scanner(System.in);
        int Day = s3.nextInt();

		int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		boolean pan = (Year % 4 == 0 && Year % 100 != 0) || (Year % 100 == 0 && Year % 400 == 0);
		if(pan){
			days[1] = 29;
		}
		int day = 0;
		for (int i = 0; i < Mon; i++) {
			day += days[i];
		}
		System.out.println(day);

	}

	
}